/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.handlers.commands.call;

import com.hercules.android.receiver.AndroidReceiver;

import java.util.List;

/**
 * This interface defines the contract for implementations that will write and read objects from a persistent storage.
 * <p>
 * <b>Thread Safety:</b> Implementations are required to be thread safe after initialization has taken place.
 *
 * @author DanLazar, orial
 * @version 1.0
 */
public interface ObjectPersistence {
    /**
     * This method will write the given byte arrays into the file.
     *
     * @param object the encrypted object
     * @param receiver the current android receiver
     * @throws IllegalArgumentException if object is null, or any field of the object is null/empty, or if receiver is
     * incorrect
     * @throws ObjectPersistenceException if any error occurs while writing the encrypted object
     */
    void writeObject(EncryptedObject object, AndroidReceiver receiver) throws ObjectPersistenceException;

    /**
     * This method will read the encrypted objects from the persistence.
     *
     * @param receiver the current android receiver
     * @return a list of EncryptedObject objects, it can be empty
     * @throws IllegalArgumentException if receiver is incorrect
     * @throws ObjectPersistenceException if any error occurs while reading the encrypted objects
     */
    List<EncryptedObject> readObjects(AndroidReceiver receiver) throws ObjectPersistenceException;
}